package com.edu.exam.enums.system;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 文件分类枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum FileCategory implements BaseEnum {

    IMAGE("IMAGE", "图片"),
    VIDEO("VIDEO", "视频"),
    AUDIO("AUDIO", "音频"),
    DOCUMENT("DOCUMENT", "文档"),
    ARCHIVE("ARCHIVE", "压缩包"),
    SPREADSHEET("SPREADSHEET", "电子表格"),
    PRESENTATION("PRESENTATION", "演示文稿"),
    TEXT("TEXT", "文本文件"),
    OTHER("OTHER", "其他");

    private final String code;
    private final String description;

    FileCategory(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static FileCategory fromCode(String code) {
        for (FileCategory category : values()) {
            if (category.getCode().equals(code)) {
                return category;
            }
        }
        throw new IllegalArgumentException("Unknown FileCategory code: " + code);
    }
    public static FileCategory fromDescription(String description) {
        for (FileCategory value : values()) {
            if (value.getDescription().equals(description)) {
                return value;
            }
        }
        throw new IllegalArgumentException("Unknown FileCategory description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}